// const LOGIN_API = '/api/Ecp.OnlineUser.apiLogin'
import {API_PRE, getApiJson, invoke} from './base'
// const localStorage = window.localStorage

const entityEdit = {
  // 后台更新prepareEdit接口添加editType, addContractEmployeeId字段,默认为null
  prepareEdit (pageCode, entityId, editType = null, addContractEmployeeId = null, args = {}) {
    let url = API_PRE + pageCode
    return getApiJson(url, _.omitBy(_.extend({
      entityId: entityId,
      editType: editType,
      addContractEmployeeId: addContractEmployeeId
    }, args), _.isNull))
  },
  prepareView (unitCode, entityId = null) {
    let url = API_PRE + 'Ecp.EntityView.vdp'
    return getApiJson(url, {
      unitCode: unitCode,
      entityId: entityId
    })
  },
  saveEntity (unitCode, data, args) {
    args = _.extend({data: data}, args)
    // console.log(args)
    let url = API_PRE + unitCode + '.save'
    return invoke(url, args)
  }
  // getListData(context, pageCode, args, callback){
  //   // let url = JDT_PRE + args.unitCode + '.getListData.jdt'
  //   let url = API_PRE + args.unitCode + '.getListData' + API_SUFFIX
  //   let postArgs = {
  //     args:args,
  //     pageCode: pageCode
  //   }
  //   args["pageCode"] = pageCode
  //   return context.$http.get(url, args)
  //   .then((res)=>{
  //     callback(res)
  //   })
  //   .catch((err)=>{
  //     //error
  //   })
  // }
}
export {entityEdit}
